package com.lh.dao;

import com.lh.entity.Address;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: LuoHang
 * @Date: 2021/2/13 17:05
 * @Description
 */
@Repository
public class AddressDao {
    @Autowired
    private SqlSessionTemplate sessionTemplate;

    public List<Address> getAddress(Map<String,Object> map) {
        return sessionTemplate.selectList("AddressMapper.getAddress",map);
    }

    public Address getAddressById(Integer id){
        return sessionTemplate.selectOne("AddressMapper.getAddressById",id);
    }

    public int addAddress(Address address){
        return sessionTemplate.insert("AddressMapper.addAddress",address);
    }

    public int updateAddress(Map<String,Object> map){
        return sessionTemplate.update("AddressMapper.updateAddress",map);
    }

    public Address getAddressByIdOn(Integer id){
        return sessionTemplate.selectOne("AddressMapper.getAddressByIdOn",id);
    }
}
